#!/bin/bash
sed -i 's/main$/main contrib non-free/g' /etc/apt/sources.list

apt-get -y update && apt-get -y upgrade

apt-get -y install lsb-release

mkdir -p /usr/local/src/ispcp
cd /usr/local/src/ispcp

wget http://sourceforge.net/projects/ispcp/files/ispCP%20Omega/ispCP%20Omega%201.0.7/ispcp-omega-1.0.7.tar.bz2
tar -xvf ispcp-omega-*
cd ispcp-omega-*

DEBIAN_FRONTEND=noninteractive apt-get -y install $(cat ./docs/Debian/debian-packages-`lsb_release -cs`)

make install
cp -R /tmp/ispcp/* /

#mysql_secure_installation

#Mot de passe mysql
nv_pass=$1
echo "set password for root@localhost=password('$nv_pass');" >> /root/nv_pass_sql
mysql -u root --password="" < /root/nv_pass_sql

cd /var/www/ispcp/engine/setup
perl ./ispcp-setup

#rm -fR /tmp/ispcp

sed -i 's/listen-on /\/\/listen-on/g' /etc/bind/named.conf.options 

ip=`ifconfig  eth0 | grep "inet ad"|awk  '{print $2}' | sed 's/adr://g'`
sed -i 's/allow-recursion { 127.0.0.1;/allow-recursion { 127.0.0.1;$ip;/g' /etc/bind/named.conf.option

/etc/init.d/bind9 restart

hostname=`hostname`
echo http://$hostname

